home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / embedded / develop / symcoff.arc / PSYMS.H < prev    next >
C/C++ Source or Header  |  1988-08-30  |  6KB  |  214 lines

  1. /* Copyright 1985 by Motorola Inc. */ 
  2. /* @(#)psyms.h    2.1 */
  3. /*        Storage Classes are defined in pstrclss.h  */
  4. #include "pstrclss.h"
  5.  
  6. /*        Number of characters in a symbol name */
  7. #define  SYMNMLEN    8
  8. /*        Number of characters in a file name */
  9. #define  FILNMLEN    14
  10. /*        Number of array dimensions in auxiliary entry */
  11. #define  DIMNUM        4
  12.  
  13.  
  14. struct syment
  15. {
  16.     union
  17.     {
  18.         char        _n_name[SYMNMLEN];    /* old COFF version */
  19.         struct
  20.         {
  21.             long    _n_zeroes;    /* new == 0 */
  22.             long    _n_offset;    /* offset into string table */
  23.         } _n_n;
  24.         char        *_n_nptr[2];    /* allows for overlaying */
  25.     } _n;
  26.     long            n_value;    /* value of symbol */
  27.     short            n_scnum;    /* section number */
  28.     unsigned short        n_type;        /* type and derived type */
  29.     char            n_sclass;    /* storage class */
  30.     char            n_numaux;    /* number of aux. entries */
  31. };
  32.  
  33. #define n_name        _n._n_name
  34. #define n_nptr        _n._n_nptr[1]
  35. #define n_zeroes    _n._n_n._n_zeroes
  36. #define n_offset    _n._n_n._n_offset
  37.  
  38. /*
  39.    Relocatable symbols have a section number of the
  40.    section in which they are defined.  Otherwise, section
  41.    numbers have the following meanings:
  42. */
  43.         /* undefined symbol */
  44. #define  N_UNDEF    0
  45.         /* value of symbol is absolute */
  46. #define  N_ABS        -1
  47.         /* special debugging symbol -- value of symbol is meaningless */
  48. #define  N_DEBUG    -2
  49.     /* indicates symbol needs transfer vector (preload) */
  50. #define  N_TV        (unsigned short)-3
  51.  
  52.     /* indicates symbol needs transfer vector (postload) */
  53.  
  54. #define  P_TV        (unsigned short)-4
  55.  
  56. /*
  57.    The fundamental type of a symbol packed into the low 
  58.    4 bits of the word.
  59. */
  60.  
  61. #define  _EF    ".ef"
  62.  
  63. #define  T_NULL     0
  64. #define  T_ARG      1          /* function argument (only used by compiler) */
  65. #define  T_CHAR     2          /* character */
  66. #define  T_SHORT    3          /* short integer */
  67. #define  T_INT      4          /* integer */
  68. #define  T_LONG     5          /* long integer */
  69. #define  T_FLOAT    6          /* floating point */
  70. #define  T_DOUBLE   7          /* double word */
  71. #define  T_STRUCT   8          /* structure  */
  72. #define  T_UNION    9          /* union  */
  73. #define  T_ENUM     10         /* enumeration  */
  74. #define  T_MOE      11         /* member of enumeration */
  75. #define  T_UCHAR    12         /* unsigned character */
  76. #define  T_USHORT   13         /* unsigned short */
  77. #define  T_UINT     14         /* unsigned integer */
  78. #define  T_ULONG    15         /* unsigned long */
  79.  
  80. /*
  81.  * derived types are:
  82.  */
  83.  
  84. #define  DT_NON      0          /* no derived type */
  85. #define  DT_PTR      1          /* pointer */
  86. #define  DT_FCN      2          /* function */
  87. #define  DT_ARY      3          /* array */
  88.  
  89. /*
  90.  *   type packing constants
  91.  */
  92.  
  93. #define  N_BTMASK     017
  94. #define  N_TMASK      060
  95. #define  N_TMASK1     0300
  96. #define  N_TMASK2     0360
  97. #define  N_BTSHFT     4
  98. #define  N_TSHIFT     2
  99.  
  100. /*
  101.  *   MACROS
  102.  */
  103.  
  104.     /*   Basic Type of  x   */
  105.  
  106. #define  BTYPE(x)  ((x) & N_BTMASK)
  107.  
  108.     /*   Is  x  a  pointer ?   */
  109.  
  110. #define  ISPTR(x)  (((x) & N_TMASK) == (DT_PTR << N_BTSHFT))
  111.  
  112.     /*   Is  x  a  function ?  */
  113.  
  114. #define  ISFCN(x)  (((x) & N_TMASK) == (DT_FCN << N_BTSHFT))
  115.  
  116.     /*   Is  x  an  array ?   */
  117.  
  118. #define  ISARY(x)  (((x) & N_TMASK) == (DT_ARY << N_BTSHFT))
  119.  
  120.     /* Is x a structure, union, or enumeration TAG? */
  121.  
  122. #define ISTAG(x)  ((x)==C_STRTAG || (x)==C_UNTAG || (x)==C_ENTAG)
  123.  
  124. #define  INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(DT_PTR<<N_BTSHFT)|(x&N_BTMASK))
  125.  
  126. #define  DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
  127.  
  128. /*
  129.  *    AUXILIARY ENTRY FORMAT
  130.  */
  131.  
  132. union auxent
  133. {
  134.     struct
  135.     {
  136.         long        x_tagndx;    /* str, un, or enum tag indx */
  137.         union
  138.         {
  139.             struct
  140.             {
  141.                 unsigned short    x_lnno;    /* declaration line number */
  142.                 unsigned short    x_size;    /* str, union, array size */
  143.             } x_lnsz;
  144.             long    x_fsize;    /* size of function */
  145.         } x_misc;
  146.         union
  147.         {
  148.             struct            /* if ISFCN, tag, or .bb */
  149.             {
  150.                 long    x_lnnoptr;    /* ptr to fcn line # */
  151.                 long    x_endndx;    /* entry ndx past block end */
  152.             }     x_fcn;
  153.             struct            /* if ISARY, up to 4 dimen. */
  154.             {
  155.                 unsigned short    x_dimen[DIMNUM];
  156.             }     x_ary;
  157.         }        x_fcnary;
  158.         unsigned short  x_tvndx;        /* tv index */
  159.     }     x_sym;
  160.     struct
  161.     {
  162.         char    x_fname[FILNMLEN];
  163.     }     x_file;
  164.         struct
  165.         {
  166.                 long    x_scnlen;          /* section length */
  167.                 unsigned short  x_nreloc;  /* number of relocation entries */
  168.                 unsigned short  x_nlinno;  /* number of line numbers */
  169.         }       x_scn;
  170.  
  171.     struct
  172.     {
  173.          long        x_tvfill;    /* tv fill value */
  174.         unsigned short    x_tvlen;    /* length of .tv */
  175.         unsigned short    x_tvran[2];    /* tv range */
  176.     }    x_tv;    /* info about .tv section (in auxent of symbol .tv)) */
  177.     struct
  178.     {
  179.         long        x_tagindx;    /* index of symbol in symbol table */
  180.         char        x_sign;        /* '+' or '-' */
  181.         char        x_name[SYMNMLEN];
  182.     }    x_expr;
  183. };
  184.  
  185. #define    SYMENT    struct syment
  186. #define    SYMESZ    18    /* sizeof(SYMENT) */
  187.  
  188. #define    AUXENT    union auxent
  189. #define    AUXESZ    18    /* sizeof(AUXENT) */
  190.  
  191. /* maximum number of auxilary expressions per symbol    */
  192. #define MAX_AUX_EXPR    7
  193.  
  194. /*    Defines for "special" symbols   */
  195.  
  196. #if VAX
  197. #define _ETEXT    "_etext"
  198. #define _EDATA    "_edata"
  199. #define _END    "_end"
  200. #else
  201. #define _ETEXT    "etext"
  202. #define _EDATA    "edata"
  203. #define _END    "end"
  204. #endif
  205.  
  206. #define _START    "_start"
  207.  
  208. #define _TVORIG    "_tvorig"
  209. #define _TORIGIN    "_torigin"
  210. #define _DORIGIN    "_dorigin"
  211.  
  212. #define _SORIGIN    "_sorigin"
  213. /* Copyright 1985 by Motorola Inc. */
  214.